package com.darkglasses.bm.utils;

import org.springframework.stereotype.Component;

import java.io.*;

public class FileWriteUtil {

    private File file;
    public FileWriteUtil(File file) {
        this.file = file;
    }
    public synchronized  boolean write(String data) {
        try ( OutputStreamWriter output = new OutputStreamWriter(new FileOutputStream(file, true), "utf-8")){
            output.write(data);
        } catch (Exception e) {
            return false;
        }
        return true;
    }

}
